<?php
$_this =& $this;

/* @var $_this View */
/* @var $form FormHelper */
/* @var $editForm EditFormHelper */
/* @var $html HtmlHelper */
/* @var $ehtml EHtmlHelper */
/* @var $javascript JavascriptHelper */
/* @var $jqax JqaxHelper */
/* @var $filterBlock FilterBlock */

if (count($list->rows)) {

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        if (Auth::o()->is('admin')) {
            ?><th class="nw"><?php
                ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'client', 'msg'=>'client', 'domain'=>$po_domain));?><?php
            ?></th><?php
        }
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'income', 'msg'=>'income', 'domain'=>$po_domain));?><?php
        ?></th><?php
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'outcome', 'msg'=>'outcome', 'domain'=>$po_domain));?><?php
        ?></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($list->rows as $item) {
        $class = '';
        if ($i++ % 2 != 0) {
            $sep = strlen($class) ? ' ' : '';
            $class .= $sep.'altrow';
        }
        $class = strlen($class) ? ' class="'.$class.'"' : '';

        ?><tr <?=$class;?>><?php
            if (Auth::o()->is('admin')) {
                ?><td class="nw"><?php
                    ?><?=(!empty($item['Client']['name'])) ? $item['Client']['name'] : "—";?><?php
                ?></td><?php
            }
            ?><td class="nw align-r"><?php
                ?><?=(!empty($item[0]['income'])) ? $item[0]['income'] : "—";?><?php
            ?></td><?php
            ?><td class="nw align-r"><?php
                ?><?=(!empty($item[0]['outcome'])) ? $item[0]['outcome'] : "—";?><?php
            ?></td><?php
        ?></tr><?php
    }
    if (Auth::o()->is('admin') && !empty($total)) {
        $class = '';
        if ($i++ % 2 != 0) {
            $sep = strlen($class) ? ' ' : '';
            $class .= $sep.'altrow';
        }
        $class = strlen($class) ? ' class="'.$class.'"' : '';

         ?><tr <?=$class;?>><?php
            ?><td class="nw align-r"><?php
                ?><strong><?php
                    ?><?=__d(null, 'Total', true).':';?><?php
                ?><strong><?php
            ?></td><?php
            ?><td class="nw align-r"><?php
                ?><strong><?php
                    ?><?=(!empty($total['income'])) ? $total['income'] : "—";?><?php
                ?><strong><?php
            ?></td><?php
            ?><td class="nw align-r"><?php
                ?><strong><?php
                    ?><?=(!empty($total['outcome'])) ? $total['outcome'] : "—";?><?php
                ?></strong><?php
            ?></td><?php
        ?></tr><?php
    }
?></tbody><?php
?></table><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'List is empty', true);?><?php
    ?></span><?php
}

?>